package com.shuguang.medicalcare;

import androidx.appcompat.app.ActionBar;
import androidx.appcompat.app.AppCompatActivity;

import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.util.Log;

public class Splash extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        Thread myThread = new Thread(){
            @Override
            public void run(){
                try {

                    SharedPreferences userSp = getSharedPreferences("userinfo",MODE_PRIVATE);
                    String str = new String(userSp.getString("token","")) ;
                    Log.i("token", "token: "+str);
                    String defStr = new String("");

                    if(str.equals(defStr)){
                        sleep(3000);
                        Intent it= new Intent(getApplicationContext(),MainActivity.class);
                        startActivity(it);
                        finish();
                    }else{
                        sleep(3000);
                        Intent it= new Intent(getApplicationContext(), ListSelect.class);
                        startActivity(it);
                        finish();
                    }
//                    Log.i("SharedPreferences", str);





//                    String abc='abc';
//                    Toast.makeText(getApplicationContext(),abc,Toast.LENGTH_SHORT).show();




                }catch (Exception e){
                    e.printStackTrace();
                }
            }
        };
        myThread.start();

        setContentView(R.layout.activity_splash);
        ActionBar actionBar=getSupportActionBar();
        if(actionBar!=null){
            actionBar.hide();
        }


//        @SuppressLint("WrongConstant") SharedPreferences UserSP = getSharedPreferences("userinfo",MODE_ENABLE_WRITE_AHEAD_LOGGING );

//        Thread myTherd=new Thread()
    }
}